package com.deco.domain.vo.sys;

import org.apache.commons.lang3.StringUtils;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class CmsUserVo implements java.io.Serializable {

    private static final long serialVersionUID = 3332701269636106490L;

    // Fields

    private Integer id;
    private String userName;
    private String password;
    private String email;
    private String mobilPhone;
    private String roles;
    private Integer type;
    private Integer status;
    private Timestamp dtmLastLogin;
    private Integer loginCount;
    private Integer createBy;
    private Timestamp createTime;
    private Integer updateBy;
    private Timestamp updateTime;
    private String confirmPassword;
    private String roleName;
    private List<CmsRoleVo> rolelist;
    /**
     * 创建人Name
     */
    private String createByName;

    /** default constructor */
    public CmsUserVo() {
    }

    // Property accessors

    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUserName() {
        return this.userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return this.password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return this.email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getMobilPhone() {
        return this.mobilPhone;
    }

    public void setMobilPhone(String mobilPhone) {
        this.mobilPhone = mobilPhone;
    }

    public String getRoles() {
        return this.roles;
    }

    public void setRoles(String roles) {
        this.roles = roles;
    }

    public Integer getType() {
        return this.type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getStatus() {
        return this.status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Timestamp getDtmLastLogin() {
        return this.dtmLastLogin;
    }

    public void setDtmLastLogin(Timestamp dtmLastLogin) {
        this.dtmLastLogin = dtmLastLogin;
    }

    public Integer getLoginCount() {
        return this.loginCount;
    }

    public void setLoginCount(Integer loginCount) {
        this.loginCount = loginCount;
    }

    public Integer getCreateBy() {
        return this.createBy;
    }

    public void setCreateBy(Integer createBy) {
        this.createBy = createBy;
    }

    public Timestamp getCreateTime() {
        return this.createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    public Integer getUpdateBy() {
        return this.updateBy;
    }

    public void setUpdateBy(Integer updateBy) {
        this.updateBy = updateBy;
    }

    public Timestamp getUpdateTime() {
        return this.updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }

    public String getConfirmPassword() {
        return confirmPassword;
    }

    public void setConfirmPassword(String confirmPassword) {
        this.confirmPassword = confirmPassword;
    }

    /**
     * @return the createByName
     */
    public String getCreateByName() {
        return createByName;
    }

    /**
     * @param createByName
     *            the createByName to set
     */
    public void setCreateByName(String createByName) {
        this.createByName = createByName;
    }

    public List<CmsRoleVo> getRolelist() {
        return rolelist;
    }

    public void setRolelist(List<CmsRoleVo> rolelist) {
        this.rolelist = rolelist;
    }

    public List<String> userRoles(){
        ArrayList<String> lst = new ArrayList<>();
        Arrays.asList(StringUtils.split(roles,",")).forEach(x->{
            if(StringUtils.isNotEmpty(x)){
                lst.add(x);
            }
        });
        return lst;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    @Override
    public String toString() {
        return "CmsUserVo{" +
                "id=" + id +
                ", userName='" + userName + '\'' +
                ", password='" + password + '\'' +
                ", email='" + email + '\'' +
                ", mobilPhone='" + mobilPhone + '\'' +
                ", roles='" + roles + '\'' +
                ", type=" + type +
                ", status=" + status +
                ", dtmLastLogin=" + dtmLastLogin +
                ", loginCount=" + loginCount +
                ", createBy=" + createBy +
                ", createTime=" + createTime +
                ", updateBy=" + updateBy +
                ", updateTime=" + updateTime +
                ", createByName='" + createByName + '\'' +
                '}';
    }
}